import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Rocket } from '@/entity/rocket/rocket.entity';

@Injectable()
export class RocketService {
  constructor(
    @InjectRepository(Rocket)
    private RocketRepository: Repository<Rocket>,
  ) {}

  async insert(postParams: any): Promise<any> {
    return this.RocketRepository.save(postParams);
  }

  async findCollect(publish_id: string, userId: string): Promise<any> {
    return this.RocketRepository.find({ where: { publish_id, userId } });
  }

  async findAll(): Promise<any> {
    return this.RocketRepository.find();
  }

  async findCollectByUserId(userId: string): Promise<Rocket[]> {
    return this.RocketRepository.find({ where: { userId } });
  }
}
